Object.defineProperty(exports, "__esModule", {
  value: !0
}), exports.default = void 0;
var e = require("../../../@babel/runtime/helpers/objectSpread2"),
  r = require("../../../@babel/runtime/helpers/regeneratorRuntime"),
  t = require("../../../@babel/runtime/helpers/slicedToArray"),
  n = require("../../../@babel/runtime/helpers/asyncToGenerator"),
  a = require("../../../lib/@reduxjs/toolkit/index"),
  i = require("../../../config/index"),
  s = (0, a.createSlice)({
    name: "global",
    initialState: {
      customerServicePhone: "",
      customerServiceVx: "",
      bannerList: [],
      share: {},
      driverClass: [],
      mechanicalClass: [],
      machineConfig: {},
      sortClass: [{
        name: "最新",
        id: 0
      }, {
        name: "推荐",
        id: 1
      }],
      userActionHistory: {
        closeBuyBuoy: !1
      },
      isShowFreeInviteDialog: !1
    },
    reducers: {
      setState: function (e, r) {
        var t = r.payload;
        Object.assign(e, t)
      },
      reducerState: function (e, r) {
        (0, r.payload)(e)
      }
    }
  }),
  c = s.reducer,
  o = s.actions,
  u = s.name,
  l = function (e) {
    if (!e) return [];
    var r = [{
        id: "1",
        mode: i.typeMode.seeking,
        name: "求租"
      }, {
        id: "2",
        mode: i.typeMode.hire,
        name: "出租"
      }, {
        id: "7",
        mode: i.typeMode.recruit,
        name: "驾驶员招聘"
      }
      // , {
      //   id: "3",
      //   mode: i.typeMode.askBuy,
      //   name: "求购"
      // }, {
      //   id: "4",
      //   mode: i.typeMode.sell,
      //   name: "出售"
      // }
    ];
    return e.forEach((function (e) {
      var t = r.find((function (r) {
        return r.id === e.page_value
      }));
      t && (e.mode = t.mode)
    })), e
  },
  d = {
    name: u,
    reducer: c,
    actions: e(e({}, o), {}, {
      getBannerData: function (e) {
        return function () {
          var a = n(r().mark((function n(a, i) {
            var s, c, u, d, f, p, v, m, h, b, g, x;
            return r().wrap((function (r) {
              switch (r.prev = r.next) {
                case 0:
                  if (c = i(), u = c.global, d = u.bannerList, null !== (s = d) && void 0 !== s && s.length && !e) {
                    r.next = 10;
                    break
                  }
                  return r.next = 5;
                case 5:
                  v = r.sent,  h = {
                    content: {
                      "time": 1703408844,
                      "contact": "18884052753",
                      "addr": {
                        "province": {
                          "id": "17",
                          "name": "江西"
                        },
                        "city": {
                          "id": "240",
                          "name": "上饶"
                        }
                      },
                      "share": {
                        "webpageUrl": "http://m.zhaogongdi.com/qiuzu/?code=ugVX10tv31VM110&source=XCX",
                        "userName": "gh_fe945caa0394",
                        "path": "/pages/index/index?invite_code=ugVX10tv31VM110&source=XCX",
                        "title": "全国机械租赁、二手交易平台",
                        "description": "鱼泡机械网提供挖掘机、推土机、铣刨机、平地机等各种工程机械出租、机械租赁服务，方便建筑工人、施工队高效快捷地寻找靠谱的建筑工程机械。",
                        "thumbData": "http://statics.zhaogongdi.com/images/xcx/share/defalutCover.png"
                      },
                      "file_domain": "http://statics.zhaogongdi.com",
                      "default_cover": "http://statics.zhaogongdi.com/common/default_cover.png",
                      "default_header": "http://statics.zhaogongdi.com/common/default_header.png",
                      "android_push": true,
                      "app_update": false,
                      "open_screen_scale": "",
                      "banner": [{
                        "id": "11",
                        "image": "http://statics.zhaogongdi.com/images/banner/20201203/H8WT681606996799.png",
                        "url": "../personal/menber",
                        "link_type": "0"
                      }],
                      "icon": [{
                        "id": "1",
                        "title": "机械求租",
                        "icon": "http://statics.zhaogongdi.com/images/icon/20230220/UX3A7T1676875812.png",
                        "page_type": "fixed",
                        "page_value": "1",
                        "unique_id": "63f3316444d42",
                        "badge": "热门",
                        "updated_at": "2023-02-21 10:18:44"
                      }, {
                        "id": "2",
                        "title": "机械出租",
                        "icon": "http://statics.zhaogongdi.com/images/icon/20230220/4uYu2A1676882844.png",
                        "page_type": "fixed",
                        "page_value": "2",
                        "unique_id": "63f3316444d43",
                        "badge": "热门",
                        "updated_at": "2023-02-21 10:19:15"
                      }, {
                        "id": "4",
                        "title": "机械求购",
                        "icon": "http://statics.zhaogongdi.com/images/icon/20230220/t9HM361676884232.png",
                        "page_type": "fixed",
                        "page_value": "3",
                        "unique_id": "63f338fa255b0",
                        "badge": "",
                        "updated_at": "2023-02-21 11:17:58"
                      }, {
                        "id": "3",
                        "title": "机械出售",
                        "icon": "http://statics.zhaogongdi.com/images/icon/20230220/WtxMMY1676884210.png",
                        "page_type": "fixed",
                        "page_value": "4",
                        "unique_id": "63f338d30b1f0",
                        "badge": "",
                        "updated_at": "2023-02-22 15:15:10"
                      }, {
                        "id": "6",
                        "title": "订阅信息",
                        "icon": "http://statics.zhaogongdi.com/images/icon/20230220/8A82x41676884276.png",
                        "page_type": "fixed",
                        "page_value": "6",
                        "unique_id": "63f3392531cf7",
                        "badge": "",
                        "updated_at": "2023-02-21 10:20:24"
                      }, {
                        "id": "7",
                        "title": "司机招聘",
                        "icon": "http://statics.zhaogongdi.com/images/icon/20230220/MwY0Tt1676884295.png",
                        "page_type": "fixed",
                        "page_value": "7",
                        "unique_id": "63f33939abcc1",
                        "badge": "",
                        "updated_at": "2023-02-21 10:20:42"
                      }, {
                        "id": "5",
                        "title": "建筑招工",
                        "icon": "http://statics.zhaogongdi.com/images/icon/20230220/9u5Y4t1676884254.png",
                        "page_type": "fixed",
                        "page_value": "5",
                        "unique_id": "63f3390e938bf",
                        "badge": "",
                        "updated_at": "2023-04-24 11:30:33"
                      }, {
                        "id": "8",
                        "title": "供应商",
                        "icon": "http://statics.zhaogongdi.com/images/icon/20230220/7U138H1676884314.png",
                        "page_type": "fixed",
                        "page_value": "8",
                        "unique_id": "63f3394d5e60f",
                        "badge": "",
                        "updated_at": "2023-02-20 19:14:01"
                      }]
                    }
                  },h.content.share.title = '一机在手保你无忧', h.content.share.thumbData = 'https://mp-78644cf8-2fa7-4805-8999-9c23996903e0.cdn.bspapp.com/微信图片_20231224171731.jpg', b = l(null === (f = h.content) || void 0 === f ? void 0 : f.icon), null !== (p = h.content) && void 0 !== p && p.icon && a(o.setState({
                    customerServicePhone: null === (g = h.content) || void 0 === g ? void 0 : g.contact,
                    bannerList: b,
                    share: null === (x = h.content) || void 0 === x ? void 0 : x.share
                  })), d = b;
                case 10:
                  return r.abrupt("return", d);
                case 11:
                case "end":
                  return r.stop()
              }
            }), n)
          })));
          return function (e, r) {
            return a.apply(this, arguments)
          }
        }()
      },
      getDriverClass: function () {
        return function () {
          var e = n(r().mark((function e(n, a) {
            var i, s, c, u, l, d;
            return r().wrap((function (e) {
              for (;;) switch (e.prev = e.next) {
                case 0:
                  if (i = a(), s = i.global, (c = s.driverClass).length) {
                    e.next = 9;
                    break
                  }
                  return e.next = 5, $.request["GET/business/driver/type/tree/list"]({
                    source: "XCX",
                    tree: 1
                  });
                case 5:
                  u = e.sent, l = t(u, 1), l[0].data.map(item => {
                    item.name = item.typeName
                    if (item.children) {
                      item.children.map((item1) => {
                        item1.name = item1.typeName
                      })
                    }
                  }), (d = l[0].data) && n(o.setState({
                    driverClass: d
                  })), c = d;
                case 9:
                  return e.abrupt("return", c);
                case 10:
                case "end":
                  return e.stop()
              }
            }), e)
          })));
          return function (r, t) {
            return e.apply(this, arguments)
          }
        }()
      },
      getMechanicalClass: function () {
        return function () {
          var e = n(r().mark((function e(n, a) {
            var i, s, c, u, l, d;
            return r().wrap((function (e) {
              for (;;) switch (e.prev = e.next) {
                case 0:
                  if (i = a(), s = i.global, (c = s.mechanicalClass).length) {
                    e.next = 9;
                    break
                  }
                  return e.next = 5, $.request["GET/business/excavator/model/tree/list"]();
                case 5:
                  function setName(data) {
                    data.map((item) => {
                      item.name = item.modelName ? item.modelName : ''
                      if (item.children) {
                        setName(item.children)
                      }
                    })
                  };
                  u = e.sent, l = t(u, 1),
                    setName(l[0].data), console.log(l[0].data), (d = l[0]).data && n(o.setState({
                      mechanicalClass: d.data
                    })), c = d.data;
                case 9:
                  return e.abrupt("return", c);
                case 10:
                case "end":
                  return e.stop()
              }
            }), e)
          })));
          return function (r, t) {
            return e.apply(this, arguments)
          }
        }()
      },
      getMachineConfig: function () {
        return function () {
          var e = n(r().mark((function e(n) {
            var a, i, s;
            return r().wrap((function (e) {
              switch (e.prev = e.next) {
                case 0:
                  return e.next = 2;
                case 2:
                  a = e.sent,console.log('----a-----'),console.log(a), i = t(a, 1), (s = i[0]).content && n(o.setState({
                    machineConfig: s.content.data
                  }));
                case 6:
                case "end":
                  return e.stop()
              }
            }), e)
          })));
          return function (r) {
            return e.apply(this, arguments)
          }
        }()
      }
    })
  };
exports.default = d;